﻿using System;

namespace Epitech.Krisk.Kinect.Sensor.Gestures.Swipes
{
    public class LeftHandSwipe : SwipeGestureDetector
    {
        private static LeftHandSwipe _instance;

        public static LeftHandSwipe Instance
        {
            get
            {
                if (_instance == null)
                    _instance = new LeftHandSwipe();
                return _instance;
            }
        }

        public LeftHandSwipe(int numberOfGestureAnalyzed = 20, int minimalPeriodBetweenGesture = 0)
            : base(numberOfGestureAnalyzed, minimalPeriodBetweenGesture)
        {
        }

        protected override void LookForGesture()
        {
            if (ScanPositions((p1, p2) => Math.Abs(p2.Y - p1.Y) < SwipeMaximalHeight, // Height
                              (p1, p2) => p2.X - p1.X > -0.01f, // Progression to right
                              (p1, p2) => Math.Abs(p2.X - p1.X) > SwipeMinimalLengthH, // Length
                              SwipeMininalDuration, SwipeMaximalDuration)) // Duration
            {
                RaiseGestureDetected(GestureType.SwipeToRight);
                return;
            }
       }
    }
}